package com.yy.device.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * 设备功能码枚举
 *
 * @author sunzhiqiang
 * @date 2022/6/21 15:18:50
 */
public enum DeviceFunctionEnum {
    /*开关-打开*/
    OPEN(6),
    /*开关-关闭*/
    CLOSED(6),
    /*读取状态*/
    READ(3);

    @Getter
    private final int type;

    DeviceFunctionEnum(int type) {
        this.type = type;
    }

    public static DeviceFunctionEnum getEnumByType(int type) {
        return Arrays.stream(DeviceFunctionEnum.values())
                .filter(item -> item.getType() == type)
                .findFirst()
                .orElse(null);
    }
}
